// Monte Carlo approximation of Pi 

import java.util.Random;
import java.util.Scanner;

class Pi {

  public static void main (String[] args)
  {
      Random point  = new Random();
      int i,n,inside;
      double x,y;       // Coordinates of a random point 

      Scanner scan = new Scanner(System.in);
      System.out.print ("Enter the number of random points: ");
      n = scan.nextInt();

      inside = 0; 
      for (i = 1; i <= n; i++) { 
         x = point.nextDouble()*2-1;    // Generate a random point
         y = point.nextDouble()*2-1;
         if (x*x + y*y <= 1) 
            inside++; // if inside the unit circle increment counter
      }

      System.out.print ("Pi = " + 4*(double)inside/n);
     
  }
}
